package com.wing.order.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.order.dao.InventoryJobLabelDao;
import com.wing.order.model.entity.InventoryJobLabel;
import com.wing.order.model.request.InventoryJobLabelForm;
import com.wing.order.model.response.InventoryJobLabelVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 出/入库作业产品明细-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class InventoryJobLabelServiceImpl extends ServiceImpl<InventoryJobLabelDao, InventoryJobLabel> implements InventoryJobLabelService {

    @Autowired
    private InventoryJobLabelDao inventoryJobLabelDao;

    @Override
    public int add(InventoryJobLabelForm inventoryJobLabelForm) {

        //校验

        InventoryJobLabel inventoryJobLabel =new InventoryJobLabel();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(InventoryJobLabel.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(inventoryJobLabelForm, inventoryJobLabel, copyOptions);

        return baseMapper.insert(inventoryJobLabel);
    }

    @Override
    public List<InventoryJobLabelVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<InventoryJobLabelVO> pageList4app(Page page, Map<String, Object> params) {
        List<InventoryJobLabelVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public InventoryJobLabelVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }

    @Override
    public List<InventoryJobLabelVO> getOutWorkPackList(Long jobId,Long jobProductId) {
        return inventoryJobLabelDao.getOutWorkPackList(jobId,jobProductId);
    }

    @Override
    public List<InventoryJobLabelVO> getLabelByDeliveryDetailIdBoxId(Long deliveryDetailId, Long boxId) {
        return baseMapper.getLabelByDeliveryDetailIdBoxId(deliveryDetailId,boxId);
    }

    @Override
    public InventoryJobLabelVO getSignPackLabel(Long signId, String code, Integer inoutType,Long signProductDetailId) {
        return inventoryJobLabelDao.getSignPackLabel(signId,code,inoutType,signProductDetailId);
    }

    @Override
    public InventoryJobLabelVO getSignPackLabelNum(Long signProductDetailId) {
        return inventoryJobLabelDao.getSignPackLabelNum(signProductDetailId);
    }


}
